<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<html>
<head>
    <title>管理员登录</title>
    <!--引入elementui得样式-->
    <link href="/css/font-awesome/css/font-awesome.min.css" rel="stylesheet">
    <link href="/disk/slidercaptcha.min.css" rel="stylesheet" />
    <link type="text/css" rel="stylesheet" href="/css/index.css"/>
    <!--引入vue得依赖必须再elementui之前引入vue-->
    <script type="text/javascript" src="/js/vue.js"></script>
    <script type="text/javascript" src="/js/index.js"></script>
    <script type="text/javascript" src="/js/axios.min.js"></script>
    <script type="text/javascript" src="/js/qs.min.js"></script>

</head>
<body style="background-image: url(img/背景图.jpg);background-repeat: no-repeat;background-attachment: fixed;background-size: 100% 100%";>
<div id="login">
    <div id="captcha" v-show="bool" class=""></div>
    <div class="tou"><h2><span>AAA大医院后台管理系统</span></h2></div>
    <div id="loginBox">
        <el-form :label-position="labelPosition" :model="loginForm" status-icon :rules="loginRules" ref="ruleForm"  label-width="80px" class="demo-ruleForm" id="loginForm">
            <el-form-item label="账号:" prop="account">
                <el-input type="text" v-model="loginForm.account" autocomplete="off"></el-input>
            </el-form-item>
            <el-form-item label="密码:" prop="password">
                <el-input type="password" v-model="loginForm.password" autocomplete="off"></el-input>
            </el-form-item>
            <el-form-item>
                <el-button  class="d" type="primary" @click="login()">登录</el-button>
                <el-button  class="z" @click="zc()">注册</el-button>
            </el-form-item>
        </el-form>
    </div>
</div>
</body>

<script src="/disk/longbow.slidercaptcha.min.js"></script>

<script>


    var app=new Vue({
        el:"#login",
        data:{
            //登录的表单对象
            loginForm:{account:"",password:""},
            labelPosition:'left',
            //登录的规则
            loginRules:{
                account:[
                    { required: true, message: '请输入账号', trigger: 'blur' },
                ],
                password:[
                    { required: true, message: '请输入密码', trigger: 'blur' },
                ]
            },
            bool:false,
        },
        methods:{
            login(){
                this.$refs.ruleForm.validate((valid) => {
                    if(valid){
                        this.bool=true;
                    }
                })
            },
            zc(){
                location.href="/registration.html"
            }
        }
    });

    var captcha = sliderCaptcha({
        id: 'captcha',
        width: 280,
        height: 150,
        sliderL: 42,
        sliderR: 9,
        offset: 5,
        loadingText: '正在加载中...',
        failedText: '再试一次',
        barText: '向右滑动填充拼图',
        repeatIcon: 'fa fa-redo',
        setSrc: function () {
            return '/img/Pic' + Math.round(Math.random() * 4) + '.jpg';
        },
        onSuccess: function () {
            axios.post("/admin/admin",app.loginForm).then(resp=>{
                if(resp.data.code===200){
                    app.$message.success("登录成功");
                    window.location.href="/index.html";
                }else{
                    app.bool=false;
                    captcha.reset();
                    app.$message.error("登录失败,账号或密码错误");

                }
            })

        },
    });

</script>

<style>
    body{
        background-image: url("/img/bg1.jpg");
        background-repeat: no-repeat;
        background-size: 1536px 732px;
    }
    #login{
        /*position: relative;*/
        /*width: 525px;*/
        /*height: 216px;*/
        /*margin: 187px auto;*/
        width: 450px;
        height: 280px;
        margin: 50px auto;
        border: 2px solid gainsboro;
        background-color: rgba(0, 0, 0, 0.1);
    }
    #loginBox{
        margin: 0px 40px 25px 40px;
    }
    #loginForm{
        margin: 20px auto;
    }
    #captcha{
        display: inline-block;
        position: absolute !important;
        margin: 0px 459px !important;
    }
    .el-form-item__label{
        font-size: 18px;
        color: #1d1d1f
    }
    .el-form-item_error{
        color: #EB1212;
        font-size: 14px;
    }
    .tou{
        height:40px;
        line-height:40px;
        text-align: center
    }
    .d{
        margin-left: 38px;
    }
    .z{
        margin-left: 20px;
        margin-right: 80px;
    }
</style>
</html>